package com.yuandian.business.monitor.controller;

import com.yuandian.api.business_monitor.po.QueryBusinessStepParams;
import com.yuandian.bpm.common.core.util.R;
import com.yuandian.business.monitor.service.IBusinessStepService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 说明：业务步骤controller
 *
 * @Author linshihe
 * @Date 2022/03/01 16:12
 */
@RestController
@Api(value = "业务步骤查询接口", tags = "业务步骤查询接口")
@RequestMapping("/business/step")
public class BusinessStepController {

    @Autowired
    private IBusinessStepService businessStepService;


    /**
     * 分页查询业务步骤数据
     *
     * @param params
     * @return 通用返回对象
     */
    @PostMapping("/queryBusinessStepListPage")
	@ApiOperation("分页查询业务步骤数据")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "advancedQuery", value = "高级查询", paramType = "query", required = false, dataType = "Array"),
			@ApiImplicitParam(name = "areaCodeList", 			value = "归属城市", 			paramType = "query", 	required = false, 	dataType = "Array"),
			@ApiImplicitParam(name = "businessCodeList", 			value = "业务编码", 			paramType = "query", 	required = false, 	dataType = "Array"),
			@ApiImplicitParam(name = "stepCodeList", 			value = "步骤编码", 			paramType = "query", 	required = false, 	dataType = "Array"),
			@ApiImplicitParam(name = "dataCenter", 			value = "数据中心", 			paramType = "query", 	required = false, 	dataType = "Array"),
			@ApiImplicitParam(name = "businessHallType", 			value = "营业厅类型：   1-查营业厅ID    2-查营业厅名称", 			paramType = "query", 	required = true, 	dataType = "String"),
			@ApiImplicitParam(name = "operatorType", 			value = "操作员类型：   1-操作员ID     2-操作员名称", 			paramType = "query", 	required = true, 	dataType = "String"),
			@ApiImplicitParam(name = "systemId", 			value = "系统id", 			paramType = "query", 	required = true, 	dataType = "String"),
			@ApiImplicitParam(name = "startTime", 			value = "开始时间", 			paramType = "query", 	required = true, 	dataType = "String"),
			@ApiImplicitParam(name = "endTime", 			value = "结束时间", 			paramType = "query", 	required = true, 	dataType = "String"),
			@ApiImplicitParam(name = "startTimeUsec", 			value = "开始时间微妙值", 			paramType = "query", 	required = false, 	dataType = "Long"),
			@ApiImplicitParam(name = "endTimeUsec", 			value = "结束时间微妙值", 			paramType = "query", 	required = false, 	dataType = "Long"),
			@ApiImplicitParam(name = "pageNum",   			value = "页码", 				paramType = "query", 	required = true, 	dataType = "Long"),
			@ApiImplicitParam(name = "pageSize", 			value = "每页大小", 			paramType = "query", 	required = true, 	dataType = "Long"),
	})
    public R queryBusinessStepListPage(@RequestBody QueryBusinessStepParams params) {

        if (params.getOrderByColumn() == null||("").equals(params.getOrderByColumn())) {
            // 设置排序，默认按时间降序
            params.setOrderByColumn("end_time");
            params.setIsAsc("desc");
        }

        return R.ok(businessStepService.queryBusinessStepListPage(params));
    }
}
